const vm1=new Vue({
    el:'#menu_bg',
    data:{
        firstCateList:[],
        showFlag:false,
        secondCateList:[],
        thirdCateList:[],
    },

    methods:{
        getFirstCateList()
        {
            axios.get('/api/getCategoryListInThis',{
                params:{
                    id:0
                }
            })
                .then(rs=>{
                    this.firstCateList=rs.data.cateList
                    vm2.firstList=rs.data.cateList
                    // console.log(rs.data)
                })
        },
        getSecondList(id)
        {
            // console.log(id)
            axios.get('/api/getCategoryListInThis',{
                params:{
                    id
                }
            })
                .then(rs=>{
                    this.secondCateList=rs.data.cateList
                    // console.log("====="+JSON.stringify(this.secondCateList))
                })
        },
        getThirdList()
        {
            axios.get('/api/getCategoryListInThis',{
                params:{
                    id:3
                }
            })
                .then(rs=>{
                    this.thirdCateList=rs.data.cateList
                    vm2.thirds=rs.data.cateList
                    // console.log("====="+JSON.stringify(this.thirdCateList))
                })
        },
        gotoList(id)
        {
            window.location=`/api/BrandList.html?id=${id}`
        }
    },
    created()
    {
        this.getFirstCateList()
        this.getThirdList()
    }

})

const vm2=new Vue({
    el:'#i_bg',
    data:{
        pageInfo:'',
        firstList:[],
        products:[],
        imgStr:'http://192.168.2.106:8848/images/',
        thirds:[],
        seconds:[]
    },
    methods:{
        //新闻资讯
        getPageInfo(pageNum,pageSize)
        {
            axios({
                url:"/api/getNewsPage",
                params:
                    {
                        pageNum,
                        pageSize,

                    }}
            ).then(rs=>{
                console.log(rs.data)
                this.pageInfo=rs.data.pageInfo
                this.getProducts()
                this.getSeconds()
            })
        },
        getProducts()
        {
            for(let i in this.firstList)
            {
                console.log(i)
                axios.get("/api/selectProductsById",{
                    params:{
                        id:this.firstList[i].id
                    }
                }).then(rs=>{
                    for(p in rs.data.products)
                    {
                        this.products.unshift(rs.data.products[p])
                    }

                })
            }console.log(this.products)
        },
        getSeconds()
        {
            axios.get('/api/getCategoryListInThis',{
                params:{
                    id:2
                }
            })
                .then(rs=>{
                    this.seconds=rs.data.cateList
                })
        },
        gotoList(id) {
            window.location = `/api/BrandList.html?id=${id}`
        },
        gotoProduct(id)
        {
            window.location=`/api/Product.html?id=${id}`
        }
    },
    created()
    {
        this.getPageInfo(1,5)
    }

})


const vm3=new Vue({
    el:'#top',
    data:{
        pName:''
    },
    methods:{
        souSuo()
        {
            window.location=`/api/BrandList.html?pName=${this.pName}`
        }
    }
})